package com.zhenwei.zscm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhenwei.zscm.entity.FileEntity;
import com.zhenwei.zscm.model.dto.file.FileDTO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface IFileMapper  extends BaseMapper<FileEntity> {
    @Select("SELECT f.* " +
            "FROM file AS f " +
            "LEFT JOIN file_relation AS r ON f.guid = r.file_id " +
            "WHERE f.deleted = 0 AND r.id is null")
    @Results(id = "fileMap", value = {
            @Result(property = "guid", column = "guid"),
            @Result(property = "fileName", column = "file_name"),
            @Result(property = "fileType", column = "file_type"),
            @Result(property = "filePath", column = "file_path"),
            @Result(property = "fileSize", column = "file_size"),
            @Result(property = "cUser", column = "c_user"),
            @Result(property = "cTime", column = "c_time"),
            @Result(property = "cUserId", column = "c_user_id"),
    })
    List<FileDTO> getUnrelatedFiles();
}
